#include "Budget.h"
#include "BudgetPlanner.h"
#include "Date.h"
#include "Expense.h"
#include "ExpenseTracker.h"
#include "Priority.h"
#include "Profile.h"
#include "User.h"
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

// functions separated(just a thought)
// will take in parameters
void add(){
}
void edit(){
}
void deletee(){
}
void view(){
}

//start off with a simple search function
// limit the search keywords to date, price, comment(in the correct format)
// let date be 1, price be 2, comment 3

void search(int typeOfExpenses, int typeOfSearch, string keyword, vector<log>& list)
{
	int entryNum = 0;
    
	switch(typeOfExpenses){
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
		case 8:
			if(typeOfSearch==1)//date
            {
               for(unsigned int i=0; i<list.size(); i++)
                {
                    if((typeOfExpenses==(list.at(i).getTypeOfExpenses)) || (typeOfExpenses==8))
						//condition 1: for cases 1-7 (to search within the category)
						//condition 2: for case 8-overall
                    {
                        if(keyword == (list.at(i)).getDate())
                        {
							entryNum ++;
							cout << "Entry number: " << entryNum << endl;
                            cout << "Date: " << (list.at(i)).getDate() << endl; 
                            cout << "Type of expenses: " << typeOfExpenses << endl; 
                            cout << "Amount: " << (list.at(i)).getAmount() << endl; 
                            cout << "Comments: " << (list.at(i)).getComment() << endl; 
                        }
                    }
                }
            }
            else if(typeOfSearch==2)//price
            {
                for(unsigned int i=0; i<list.size(); i++)
                {
                    if((typeOfExpenses==(list.at(i).getTypeOfExpenses)) || (typeOfExpenses==8))
                    {
                        if(keyword == (list.at(i)).getAmount())
                        {
							entryNum ++;
							cout << "Entry number: " << entryNum << endl;
                            cout << "Date: " << (list.at(i)).getDate() << endl; 
                            cout << "Type of expenses: " << typeOfExpenses << endl; 
                            cout << "Amount: " << (list.at(i)).getAmount() << endl; 
                            cout << "Comments: " << (list.at(i)).getComment() << endl; 
                        }
                    }
                }
            }
            else if(typeOfSearch==3)//comment
            {
                for(unsigned int i=0; i<list.size(); i++)
                {
					if((typeOfExpenses==(list.at(i).getTypeOfExpenses)) || (typeOfExpenses==8))
                    {
                        if(keyword == (list.at(i)).getComment())
                        {
							entryNum ++;
							cout << "Entry number: " << entryNum << endl;
                            cout << "Date: " << (list.at(i)).getDate() << endl; 
                            cout << "Type of expenses: " << typeOfExpenses << endl; 
                            cout << "Amount: " << (list.at(i)).getAmount() << endl; 
                            cout << "Comments: " << (list.at(i)).getComment() << endl; 
                        }
                    }
                }
            }
            else
            {
                cout << "invalid search" << endl;
            }
            break;
        default:
            cout << "invalid search" << endl;
    }
}




void alerts(){
	//display notifications, simple as that
}

void functions(){
	int category;
	int function;

	int typeOfExpenses, typeOfSearch;
	string keyword;
	cout << "Please make a selection of the category you want to access: "<< endl;
	cout << "1 Accomodation 2 Academic 3 Debt 4 Food 5 Recreation 6 Transportation 7 Others 8 Overall "<< endl;
	cin >> category;
	cout << "Please make a selection of the function you want to perform: "<< endl;
	cout << "1 Add 2 Edit 3 Delete 4 View 5 Search "<< endl;
	cin >> function;

	if (function == 1){
		// call add function
	}
	//etc.

}


int main(){
	int selection;
	cout << "Welcome! Please make a selection: "<< endl;
	cout << "1 File 2 Tools 3 Help" << endl;
	cin >> selection ;

	if (selection == 1){
		int newselection;
		cout << "Please make a selection: "<< endl;
		cout << "1 Open 2 New Profile 3 Exit" << endl;
		cin >> newselection;
		if (newselection == 1){
			//open file

			alerts();
			functions();// would preferably take the name of the txtfile
		}
		else if (newselection == 2){
			//create new profile
			//write to txtfile
			alerts();
			functions();
		}
		else if (newselection == 3){
			//quit
			return 0;
		}
		else{
			cout << "Error!" << endl;
		}
	}
	else if (selection == 2){
		//currency exchange?
	}
	else if (selection == 3){
		//display user manual
	}
	else {
		cout << "Error!" << endl;
	}	


	return 0;

}
